// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)

// let indexUrl = '/api/index';

// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {
	//定义api属性
	vm.$u.api = {}
	
	// 此处使用了传入的params参数，一切自定义即可
	//首页
	// vm.$u.api.index = (params = {}) => vm.$u.get('/api/index', params);
	vm.$u.api.getIndexGoods = (params = {}) => vm.$u.get('/p/pms/book/customList', params); //首页获取商品
	vm.$u.api.getSwiperList = () => vm.$u.get('/p/ims/swiper/list1'); //首页获取轮播图
	vm.$u.api.getContentInfo = () => vm.$u.get('/p/ims/info'); //首页获取轮播图
	
	
	
	// 文章相关
	vm.$u.api.article = (params = {}) => vm.$u.get('/p/ams/article/articleList', params); //获取文章列表 √
	vm.$u.api.articleDetail = (articleId) => vm.$u.get(`/p/ams/article/${articleId}`); //获取文章详情页  √
	vm.$u.api.LikeArticle = (articleId,userId) => vm.$u.get(`/ams/article/judgeLike/${articleId}/${userId}`); //给文章点赞  √
	vm.$u.api.isLike = (articleId,userId) => vm.$u.get(`/ams/article/ifLike/${articleId}/${userId}`); //是否已经点赞  √
	vm.$u.api.addViews = (articleId) => vm.$u.get(`/p/ams/article/addViews/${articleId}`); //文章点击量+1  √
	
	
	// 用户收获地址相关
	vm.$u.api.addAddress = params => vm.$u.post('/cms/address/add',params)// 添加收获地址 √
	vm.$u.api.delAddress = (addressId) => vm.$u.get(`/cms/address/del/${addressId}`); //用户删除地址  
	vm.$u.api.getAddressList = (userId) => vm.$u.get(`/cms/address/getList/${userId}`); //用户获取个人地址列表   √
	vm.$u.api.getDefaultAddress = (userId) => vm.$u.get(`/cms/address/getDefault/${userId}`); //用户获取个人默认地址  
	vm.$u.api.updateAddress = (addressId,params) => vm.$u.post(`/cms/address/update/${addressId}`,params)// 用户修改地址信息  √
	
	
	//认证相关的
	vm.$u.api.authLogin = params => vm.$u.post('/cms/user/login',params)//登录 √
	vm.$u.api.returnPhone = (account) => vm.$u.post(`/cms/user/returnPhone/${account}`)// 用户修改密码时 判断用户账号或手机是否存在数据库 并返回 处理过的手机号 √
	vm.$u.api.judgePhoneIsTheAccount = (account,tel) => vm.$u.post(`/cms/user/judgePhoneIsTheAccount/${account}/${tel}`)// 用户修改密码时 判断用户输入的账号是否匹配手机号 √
	vm.$u.api.resetPasswd = params => vm.$u.post('/cms/user/resetPasswd',params)// 用户修改密码时 重置密码 
	vm.$u.api.judgeUserExistByTel =(tel)=> vm.$u.get(`/cms/user/judgeUserExistByTel/${tel}`)// 用户注册时 输入手机号判断是否已经注册 √
	
	vm.$u.api.authRegister = params => vm.$u.post('/cms/user/register',params)//注册 √
	vm.$u.api.updatePwd = params => vm.$u.post('/cms/user/updatePassword',params)//修改密码 √
	// vm.$u.api.authLogout = () => vm.$u.post('/api/auth/logout')//退出登录
	vm.$u.api.authOssToken = () => vm.$u.get('/aliyun/oss/policy')//获取oss token
	vm.$u.api.sendYzm = (phone) => vm.$u.get(`cms/user/getYzm/${phone}`); // 用户发送验证码 √
	vm.$u.api.varifyYzm = (phone,yzm) => vm.$u.get(`cms/user/getYzm/${phone}/${yzm}`); // 用户验证验证码√
	
	
	//用户相关的
	vm.$u.api.userInfo = params => vm.$u.get('/cms/user/info',params)//用户详情 √
	vm.$u.api.userReflashToken = params => vm.$u.get('/cms/user/reflashToken',params)//用户更新信息刷新token 
	vm.$u.api.userInfoUpdate = (id,params) => vm.$u.post(`/cms/user/update/${id}`,params)//修改用户信息 √
	vm.$u.api.userAvatar = params => vm.$u.post('/cms/user/updateHeadImg',params)//更新用户头像
	
	//商品相关的
	vm.$u.api.bookCategory = () => vm.$u.get('/p/pms/bookCategory/listTree')// 书籍分类 √
	vm.$u.api.bookSubject = () => vm.$u.get('/p/pms/subject/listAll')// 学科分类 √
	
	vm.$u.api.booksInfo = id => vm.$u.get(`/p/pms/book/${id}`)//商品详情 
	vm.$u.api.addCollect = params => vm.$u.get('/cms/bookFavority/create',params)//添加商品收藏  √
	vm.$u.api.delCollectByBid = params => vm.$u.get('/cms/bookFavority/deleteByBid',params)//取消商品收藏 √
	vm.$u.api.judgeIsCollect = bid => vm.$u.get(`/cms/bookFavority/judgeIsExists/${bid}`)//用户是否收藏该商品 √
	vm.$u.api.delCollect = id => vm.$u.get(`/cms/bookFavority/delete/${id}`)//商品列表取消商品收藏
	vm.$u.api.collectList = params => vm.$u.get('/cms/bookFavority/list',params)//商品收藏列表
	vm.$u.api.getGoodsList = (params = {}) => vm.$u.get('/p/pms/book/customList', params)//商品列表
	vm.$u.api.getCateWithSub = id => vm.$u.get(`/p/pms/subject/cate/${id}`)//商品列表
	vm.$u.api.getFileWithBookList = (params = {}) => vm.$u.get('/p/pms/book/fileBookList',params)//课件资源列表
	
	
	
	//购物车相关
	vm.$u.api.addCart = params => vm.$u.get('/cms/cart/create',params);//添加购物车  √
	vm.$u.api.cartGoods = params => vm.$u.get('/cms/cart/list',params);//购物车列表  √
	vm.$u.api.numChange = (id,params) => vm.$u.get(`/cms/cart/update/${id}`,params);//购物车商品数量改变  √
	vm.$u.api.delCartGoods = (id) => vm.$u.get(`/cms/cart/delete/${id}`);//将商品移出购物车  √
	vm.$u.api.mulDelCartGoods = params => vm.$u.get('/cms/cart/deletes',params);//将商品移出购物车  √
	vm.$u.api.cartToOrder = params => vm.$u.get('/cms/cart/getCartByCartIds',params);//从购物车去结算  
	
	
	// vm.$u.api.isCheck = cart_ids => vm.$u.patch(`/api/carts/checked`,{cart_ids});//将商品选中与否  

	//文件相关的
	vm.$u.api.audioList = params => vm.$u.get('/p/pms/book/audioBookList',params);//获取音频列表  √
	vm.$u.api.getAudio = id => vm.$u.get(`/p/pms/book/audios/${id}`);//获取音频
	vm.$u.api.fileList = params => vm.$u.get('/p/pms/book/fileBookList',params);//获取文件列表
	vm.$u.api.fileListByBid = id => vm.$u.get(`/pms/book/fileByBid/${id}`);//通过书ID获取书相关文件
	vm.$u.api.fileDownloadUrl = id => vm.$u.get(`/download/bookFile/${id}`);//通过文件id获取文件下载链接
	
	
	
	
	
	//订单相关
	vm.$u.api.createOrder = params => vm.$u.get('/oms/bookOrder/cart/create',params);//创建订单
	vm.$u.api.getComment = params => vm.$u.get('/oms/bookOrder/comment',params);//查看商品评论
	vm.$u.api.directCreateOrder = params => vm.$u.post('/oms/bookOrder/create',params);//直接购买创建订单
	vm.$u.api.getOrderDetail = oid => vm.$u.get(`/oms/bookOrder/${oid}`);//通过订单id获取订单详情
	vm.$u.api.getBookListByBids = params => vm.$u.get('/p/pms/book/ids',params);//通过书籍id数组获取书籍数组信息
	vm.$u.api.confirmPay = id => vm.$u.get(`/oms/bookOrder/outTradeNo/${id}`);//通过订单id获取订单详情
	vm.$u.api.getOrderList = params => vm.$u.get('/oms/bookOrder/user/list',params);//通过订单id获取订单详情
	vm.$u.api.confirmReceipt = oid => vm.$u.get(`/oms/bookOrder/over/${oid}`);//通过订单id确认收货
	vm.$u.api.comment = params => vm.$u.post('/oms/bookOrder/comment',params);//用户评论
	vm.$u.api.comments = params => vm.$u.post('/oms/bookOrder/comments',params);//用户多条评论
	vm.$u.api.cancleOrder = oid => vm.$u.get(`/oms/bookOrder/cancel/${oid}`);//用户取消订单
	vm.$u.api.delOrder = oid => vm.$u.get(`/oms/bookOrder/delete/${oid}`);//用户删除订单
	

}

export default {
	install
}